package sort;

import java.util.*;

public class HeapSort implements Sort {

    public class DescendingComparator implements Comparator<Comparable> {
        @Override
        public int compare(Comparable o1, Comparable o2) {
            return Integer.compare(0, o1.compareTo(o2));
        }
    }

    PriorityQueue<Comparable> heap = new PriorityQueue<>(new DescendingComparator());

    @Override
    public void sort(Comparable[] array) {
        heapSort(array, 0, array.length - 1);
    }

    public void heapSort(Comparable[] arr, int lo, int hi) {
        int length = hi - lo + 1;
        for (int i = lo; i <= hi; i++)
            heap.add(arr[i]);
        for (int i = lo; i <= hi; i++)
            arr[i] = heap.poll();

    }
}
